package com.lemon.smartsafety.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lemon.smartsafety.R;
import com.lemon.smartsafety.utils.CommonUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 项目名称：workspace
 * 类描述：
 * 创建人：Fargo
 * 创建时间：2016/8/8 16:55
 * 修改人：Fargo
 * 修改时间：2016/8/8 16:55
 * 修改备注：
 */
public class ViewFireTop extends LinearLayout {


    @Bind(R.id.txt_title)
    TextView txtTitle;
    @Bind(R.id.txt_titleSub)
    TextView txtTitleSub;
    @Bind(R.id.image_circle)
    ImageView imageCircle;
    @Bind(R.id.txt_num1)
    TextView txtNum1;
    @Bind(R.id.txt_num2)
    TextView txtNum2;
    @Bind(R.id.lineAll)
    LinearLayout lineAll;

    private View view;

    public ViewFireTop(Context context) {
        super(context);
        initView(context);
    }

    public ViewFireTop(Context context, AttributeSet attrs) {
        super(context, attrs);

        initView(context);

    }

    private void initView(Context context) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.view_fire_top, this);
        ButterKnife.bind(this, view);

    }

    public interface CallBackInterface {
        void callBackFunction(View view);

    }

    //Sky--右边按钮单独点击事件
    public interface AllClick {
        void click();
    }


    public void setAllClick(final AllClick allClick) {
        txtTitle.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                allClick.click();
            }
        });

        txtTitleSub.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                allClick.click();
            }
        });

        imageCircle.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                allClick.click();
            }
        });

        txtNum1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                allClick.click();
            }
        });

        txtNum2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                allClick.click();
            }
        });

    }


    public void setAllBg(int drawable) {
        lineAll.setBackgroundResource(drawable);
    }


    public void setTitleColor(int color) {
        txtTitle.setTextColor(color);
    }

    public void setTitleSubColor(int color) {
        txtTitleSub.setTextColor(color);
    }

    public void setNum1Color(int color) {
        txtNum1.setTextColor(getResources().getColor(color));
    }

    public void setNum2Color(int color) {
        txtNum2.setTextColor(color);
    }

    public void setTitleSize(int size) {
        int sp_1 = (int) getResources().getDimension(R.dimen.sp_1);
        txtTitle.setTextSize(sp_1 * size);
    }

    public void setTitleSubSize(int size) {
        int sp_1 = (int) getResources().getDimension(R.dimen.sp_1);
        txtTitleSub.setTextSize(sp_1 * size);
    }

    public void setNum1Size(int size) {
        int sp_1 = (int) getResources().getDimension(R.dimen.sp_1);
        txtNum1.setTextSize(sp_1 * size);
    }

    public void setNum2Size(int size) {
        int sp_1 = (int) getResources().getDimension(R.dimen.sp_1);
        txtNum2.setTextSize(sp_1 * size);
    }


    public void setTitleContent(String string) {
        txtTitle.setText(string);
    }

    public void setTitleSubContent(String string) {
        if(CommonUtil.strIsEmpty(string)){
            txtTitleSub.setVisibility(GONE);
        }else {
            txtTitleSub.setText(string);
            txtTitleSub.setVisibility(VISIBLE);
        }
    }

    public void setNum1Content(String string) {
        txtNum1.setText(string);
    }

    public void setNum2Content(String string) {
        txtNum2.setText(string);
    }


    public void setImageCircleShow(boolean v) {
        if (v) {
            imageCircle.setVisibility(VISIBLE);
        } else {
            imageCircle.setVisibility(GONE);
        }
    }

    public void setImageCircleBg(int drawable) {
        imageCircle.setBackgroundResource(drawable);
    }


}

